<?php header("Location 404.htm");Die();/*
<code>
//*/

if (ereg('^:[^ ]+ PRIVMSG [^ ]+ :?'.$GLOBALS['IRC']->GetNick(),$GLOBALS['IRC']->GetLastLine()))
{
  // nacteni a vypis plku
  $filename = 'data'.DIRECTORY_SEPARATOR.'plk.txt';
  $size = filesize($filename);
  $hlaska = '';
  $plk = array();
  $plk = spliti('^:[^ ]+ PRIVMSG [^ ]+ :?'.$GLOBALS['IRC']->GetNick(),$GLOBALS['IRC']->GetLastLine());
  $unikatni = true;
  if (file_exists($filename) && ($size > 0)) {
    $fp = fopen($filename,'r');
    $i = 0;
    while (strlen($hlaska) <= 0)
    {
      fseek($fp,rand(0,$size));
      fgets($fp);
      $hlaska = trim(fgets($fp));
      $i++;
      if ($i > 10) $hlaska = ':-(';
    }
    if (strlen($hlaska) > 0) {
      ereg('^:[^!]+',$GLOBALS['IRC']->GetLastLine(),$tmp);
      $GLOBALS['IRC']->Reply(substr($tmp[0],1).': '.$hlaska);
    }
    // zjisti jestli je zaslany plk unikatni
    fseek($fp,0);

    while (!feof($fp)){
      $radek = fgets($fp);
      if (trim(chop($radek)) == trim(chop(substr($plk[1],1))))
      {
        $unikatni = false;
      }
    }

    fclose($fp);
  }
  // ulozeni plku
  if ($unikatni){
    $fp = fopen($filename,'a');
    $ulozit = chop($plk[1]);
    if ($ulozit[0] == ':') $ulozit = trim(chop(substr($ulozit,1)));
    fputs($fp,$ulozit."\n");
    fclose($fp);
    // ulozeni statistik
    $filename = 'data'.DIRECTORY_SEPARATOR.'plkstat.txt';
    $fp = fopen($filename,'r');
    $stats = array();
    while (!feof($fp))
    {
      $nick = array();
      $pocet = array();
      $radek = fgets($fp);
      ereg('^[^ ]+',$radek,$nick);
      $pocet = split('^[^ ]+',$radek);
      if (trim($radek) != '') $stats[$nick[0]] = trim(chop($pocet[1]));
    }
    fclose($fp);

    ereg('^:[^!]+',$GLOBALS['IRC']->GetLastLine(),$tmp);
    $stats[substr($tmp[0],1)]++;

    $fp = fopen($filename,'w+');
    foreach ($stats as $nick => $pocet)
    fputs($fp,$nick.' '.$pocet."\n");
    fclose($fp);
  }
}

</code>
<lang>
</lang>
*/?>